package com.example.springcloud.storage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springcloud.storage.entity.Storage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 库存 Mapper
 */
@Mapper
public interface StorageMapper extends BaseMapper<Storage> {

    /**
     * 扣减库存 - AT 模式
     */
    int deduct(@Param("productId") Long productId, @Param("count") Integer count);

    /**
     * 冻结库存 - TCC Try
     */
    int freeze(@Param("productId") Long productId, @Param("count") Integer count);

    /**
     * 确认扣减 - TCC Confirm
     */
    int confirmDeduct(@Param("productId") Long productId, @Param("count") Integer count);

    /**
     * 取消扣减 - TCC Cancel
     */
    int cancelDeduct(@Param("productId") Long productId, @Param("count") Integer count);
}

